package sk.vrto.service.dao;

import java.util.Collection;

/**
 * Generic repository for manipulating entities
 * @param <T> Type of the entity
 * @param <K> Type of the key
 */
public interface Repository<T, K> {

    /**
     * Finds entity in the repository
     * @param key Key of the entity
     * @return Found entity, or {@code null} when there is no such entity.
     */
    T find(K key);

    /**
     * Loads all entites from the repository.
     * @return List of all entites.
     */
    Collection<T> load();

    /**
     * Inserts a new entity to repository
     * @param t New entity
     */
    void insert(T t);

    /**
     * Updates an existing entity in repository
     * @param t Updated entity
     */
    void update(T t);

    /**
     * Deletes given entity from the repository
     * @param t Entity to remove
     */
    void delete(T t);

}
